#pragma once
#ifndef  GRAPH_BASE_H_
#define GRAPH_BASE_H_

#include "BlueprintScriptLibrary/RegistAction.h"
#include "base/Control.h"
#include "GraphContainer.h"
class GraphBase;
struct GraphContext
{
    std::vector<GraphBase*>* allGraph;
    GraphBase* FindGraphById(VarBaseInt val);

};
class GraphBase : public Control
{
public:
    GraphBase() {}
    bool OnInit();
    virtual void ParseXmlElement(class TiXmlElement* ele);
    bool SetAttribute(const char* attrName, const char* attrVal);
    void OnDraw(); 
    virtual void onMouseButtonDown(int button, int x, int y);
    void onMouseMove(int x, int y);
    void onMouseButtonUp(int button, int x, int y);
    BlueprintScriptLibrary::Class* GetClass();
    virtual VarBaseInt GetInputPinNum() { return 1; }
    virtual VarBaseInt GetOuputPinNum() { return 1; }
    Vec2vbi GetOutputPinPos(int index);
    Vec2vbi GetInputPinPos(int index);
    virtual void Execute();
    FunctionPin* GetFunctionPin();
    void ConnectTo(GraphBase* graph, int index);

    Vec2vbi baseOffset;;
    VarBaseString graphName;

    bool bMouseDown{ false };
    bool bDrag{ false };
    GraphBase* nextGraph;
    VarBaseInt nextGraphId{ 0 };
    VarBaseInt graphId;

    GraphContext context;
    GraphContainer* containerParent;
    //drag
    Vec2vbi mouseDownPoint;
    Pin* pin;
};
RegisterBlueprintClass(GraphBase)
#endif

